package com.stone;

public class BinarySearch {
    public static void main(String[] args) {
        int[] array={1,3,5,7,9,10,10,11};
        int search = search(0, array.length, 5, array);
        System.out.println(search);
    }

    public static int search(int start, int end, Integer target, int[] array){

        if (start > end){
            return -1;
        }

        int mid=start +(end - start)/2;
        // System.out.println(mid);
        if (array[mid] == target){
            return mid;
        }else if (target > array[mid]){
            search(mid +1,end,target,array);
        }else{
            search(0,mid-1,target,array);
        }
        return mid;
    }
}
